package com.jeesite.common.pojo;

import com.jeesite.common.web.http.wrapper.XssHttpServletRequestWrapper;

import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;

/**
 * @ClassName WxHttpServletRequest
 * @Description 微信登录请求封装
 * @Author Spencer Zhang
 * @Date 2025/2/15 15:11
 */
public class WxHttpServletRequest extends XssHttpServletRequestWrapper {
    private Map<String, String[]> parameterMap;
    /**
     * Constructs a request object wrapping the given request.
     *
     * @param request The request to wrap
     * @throws IllegalArgumentException if the request is null
     */
    public WxHttpServletRequest(HttpServletRequest request, Map<String, String[]> parameterMap) {
        super(request);
        this.parameterMap = parameterMap;
    }

    @Override
    public Map<String, String[]> getParameterMap() {
        return Collections.unmodifiableMap(parameterMap);
    }

    @Override
    public Enumeration<String> getParameterNames() {
        return Collections.enumeration(parameterMap.keySet());
    }

    @Override
    public String[] getParameterValues(String name) {
        return parameterMap.getOrDefault(name, new String[0]);
    }

    @Override
    public String getRequestURI() {
        String old = super.getRequestURI();
        old = old.replace("/swim", "");
        return old;
    }

}